<template>
  <div class="box">
    <RenderTable 
      :superQueryFieldList="superQueryFieldList" 
      :queryParamArr = "queryParamArr"
      :defColumns="defColumns"
      :isShowDeleteBatch = "true"
      :isShowRowSelection = "true"
      :url = "url"
      @handleEdit = "handleEdit"
      ref='renderTable'
    >
    
      <template slot="btn">
        <p-button type="primary" @click="showAddModal" style="margin-right: 10px">新增</p-button>
      </template>

    </RenderTable>

    <TextbookBankModal ref='textbookBankModal' @handleSuccess = 'handleSuccess'></TextbookBankModal>

  </div>
</template>

<script type="text/javascript">
import { getDictItemsArr } from "@/utils/util";
import RenderTable from '@/components/renderTable'
import TextbookBankModal from './modules/textbookBankModal.vue'

const superQueryFieldList =
[
  {
    value: "organization",
    text: "组织",
    type: "String",
  },  
  {
    value: "empname",
    text: "员工姓名",
    type: "String",
  },
]
export default {
  data() {
    return {
      superQueryFieldList,
      queryParamArr: [
        {
          label: "技能名称",
          placeholder: "请输入技能名称",
          type: 'input',
          key: 'skillName',
          value: ''
        }
      ],
      defColumns: [
        {
          title: "序号",
          dataIndex: "",
          key: "rowIndex",
          width: 60,
          align: "center",
          customRender: (t, r, index) => {
            return parseInt(index) + 1;
          },
        },
        {
          title: "教材编码",
          align: "center",
          dataIndex: "textbookNo",
        },
        {
          title: "教材名称",
          align: "center",
          dataIndex: "textbookName",
        },
        {
          title: "教材归类",
          align: "center",
          dataIndex: "skillName",
        },
        // 没有
        {
          title: "上传人",
          align: "center",
          dataIndex: "updateBy",         
        },
        {
          title: "版本",
          align: "center",
          dataIndex: "version",       
        },
        {
          title: "附件",
          align: "center",
          dataIndex: "fileUrl",
          scopedSlots: { customRender: "url" },
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          scopedSlots: { customRender: "action" },
        },
      ],
      skillPropertyKeys: {},
      url: {
        list: '/mes-manpower/mesHrTextbookBank/list',
        delete: '/mes-manpower/mesHrTextbookBank',
        // editStatus: '/mes-manpower/mesHrSkillBank/updateStatus',
      },
    
      layout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 14 },
      },         
    }
  },
  mounted() {
    this.getAjaxGetDictItems()
  },
  methods: {

    // 获取数字字典
    getAjaxGetDictItems() {
      const arr = [
        { code: "	mes_skill_property", key: "skillPropertyKeys" },
      ];
      getDictItemsArr(this, arr);
    },

    handleEdit(record){
      this.$refs.textbookBankModal.showModal(record)
    },

    // 显示新增弹窗
    showAddModal(){
      this.$refs.textbookBankModal.showModal()
    },
    handleSuccess(){
      this.$refs.renderTable.loadData()
    }
  },
  components: {
    RenderTable,
    TextbookBankModal
  }
}
</script>

<style lang="less" scoped>
</style>

